package com.digitalchina.lxnsy.viewholder;

import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.digitalchina.lxnsy.R;
import com.digitalchina.lxnsy.entity.PlanProductVO;
import com.jude.easyrecyclerview.adapter.BaseViewHolder;

/**
 * ================================================
 * 项目名称：BigData
 * 类描述：
 * 包名：com.digitalchina.bigdata.viewholder
 * 创建人：郑皓
 * 创建时间：2018/8/1 17:10
 * 修改备注：
 * ================================================
 */

public class PlantChildHolderV2 extends BaseViewHolder<PlanProductVO.FarmOperationBean> {

    private TextView tvName;
    private TextView tvTime;
    private View vTop;
    private View vBottom;
    private ImageView ivDot;


    public PlantChildHolderV2(ViewGroup parent) {
        super(parent, R.layout.item_plant_child_v2);
        tvName = $(R.id.tv_name);
        tvTime = $(R.id.tv_time);
        vTop = $(R.id.view_top);
        vBottom = $(R.id.view_bottom);
        ivDot = $(R.id.iv_dot);
    }

    @Override
    public void setData(PlanProductVO.FarmOperationBean data) {
        super.setData(data);

        if (data.isDotColor())
            ivDot.setImageResource(R.drawable.ic_green_dot);
        else
            ivDot.setImageResource(R.drawable.ic_gray_dot);

        switch (data.getLine()) {
            case 0: // 顶部
                vTop.setVisibility(View.INVISIBLE);
                vBottom.setVisibility(View.VISIBLE);
                break;
            case 1: // 底部
                vTop.setVisibility(View.VISIBLE);
                vBottom.setVisibility(View.INVISIBLE);
                break;
            case 2: // 中间
                vTop.setVisibility(View.VISIBLE);
                vBottom.setVisibility(View.VISIBLE);
                break;
            case 3: // 只有一个操作时
                vTop.setVisibility(View.INVISIBLE);
                vBottom.setVisibility(View.INVISIBLE);
                break;
        }

        if (data.isCurOper()){
            tvName.setTextColor(getContext().getResources().getColor(R.color.app_color));
            tvTime.setTextColor(getContext().getResources().getColor(R.color.app_color));
        }else{
            tvName.setTextColor(getContext().getResources().getColor(R.color.colorFontBlack));
            tvTime.setTextColor(getContext().getResources().getColor(R.color.colorFontBlack));
        }


        tvName.setText(data.getFarmName() + "");
        tvTime.setText(data.getFarmDate() + "");

    }

}
